/* eslint-disable */
import {
  axios
} from '@/utils/request'
let prefix = '/api'
const isDev = process.env.NODE_ENV === "development"
if (!isDev) {
  prefix = window.location.origin + '/api';
}
const afunc = (url, method, params) => {
  const pa = {
    url,
    method,
  };
  if (params && method === 'GET') {
    pa.params = params;
  } else if (params && method === 'POST') {
    pa.data = params;
  }
  return axios(pa)
}
// 获取用户信息
const userInfo = (params) => afunc(`${prefix}/poros-permission/secStaff/getCurUser`, 'GET', params);
// 用户表单1
const getSaleInfo = (params) => afunc(`${prefix}/bpm-engine/saleInfo/getSaleInfo`, 'GET', params);
// 保存用户表单1
const saleInfo = (params) => afunc(`${prefix}/bpm-engine/saleInfo`, 'POST', params);
// 用户表单2
const getSaleInfoDetail = (params) => afunc(`${prefix}/bpm-engine/saleInfo/getSaleInfoDetail`, 'GET', params);
// 保存用户表单2
const addSaleDetail = (params) => afunc(`${prefix}/bpm-engine/saleInfo/addSaleDetail`, 'POST', params);
const getOrgTreeList = (params) => afunc(`${prefix}/poros-permission/secOrg/list`, 'GET', params);
// const getTaskRecordList = (params) => afunc(`${prefix}/bpm-engine/task/getTaskRecordList`, 'GET', params);
const getTaskRecordList = (params) => afunc(`${prefix}/poros-bpmengine/task/getTaskRecordList`, 'GET', params);
const getTaskList = (params) => afunc(`${prefix}/poros-bpmengine/task/getAssigneeTaskList`, 'GET', params);
const getProcessPicture = (params) => afunc(`${prefix}/poros-bpmengine/process/getProcessPicture/${params}`, 'GET');
// 同意
const completeTask = (params) => afunc(`${prefix}/poros-bpmengine/task/completeTask`, 'POST', params);
// 转办
const transferTask = (params) => afunc(`${prefix}/poros-bpmengine/task/transferTask`, 'POST', params);
//驳回
const rejectTask  = (params) => afunc(`${prefix}/poros-bpmengine/task/rejectTask`,'POST',params);

// 获取创建流程的参数
const getProcessParams  = (params) => afunc(`${prefix}/poros-bpmengine/actModel/processDefinitionKey/${params}`,'GET');
const startProcess = (params) => afunc(`${prefix}/poros-bpmengine/process/startProcess`, 'POST', params)
const getProcessDetail = (processInstanceId) => afunc(`${prefix}/poros-bpmengine/process/one/`+processInstanceId, 'GET')
// 撤回流程
const retractTask = (params) => afunc(`${prefix}/poros-bpmengine/task/retractTask`, 'POST', params)
const userList  = (params) => afunc(`${prefix}/poros-permission/secStaff/list`,'GET',params);
// 获取创建流程的参数
const getProcessParams2  = (params) => afunc(`${prefix}/bpm-engine/actModel/processDefinitionKey/${params}`,'GET');

// 流程引擎example通用接口
//
const creatExampleProcess = (params) => afunc(`${prefix}/bpm-engine-demo/example/process`, 'POST', params)
const getExampleForm = (processInstanceId) => afunc(`${prefix}/bpm-engine-demo/example/form/process/${processInstanceId}`, 'GET')
const getExampleBusiness = (processInstanceId) => afunc(`${prefix}/mes-manufacture/mfScientific/getByProcessId/${processInstanceId}`, 'GET')
const complateExampleTask = (params) => afunc(`${prefix}/bpm-engine-demo/example/task/completeTask`, 'POST', params)
// 根据插单流程ID查询实例
const getExamplemfcdList=(processInstanceId) => afunc(`${prefix}/mes-manufacture/mfProcess/insert/${processInstanceId}`, 'GET')
// 根据缺料流程实例ID查询
const getExampleqlList=(processInstanceId) => afunc(`${prefix}/mes-manufacture/mfProcess/lack/${processInstanceId}`, 'GET')
// 根据开班ID获取流程
const getStartlList=(processInstanceId) => afunc(`${prefix}/mes-manufacture/mfClassTest/getProcessId/${processInstanceId}`, 'GET')

export default {
  getOrgTreeList,
  getTaskRecordList,
  getProcessPicture,
  completeTask,
  transferTask,
  rejectTask,
  userList,
  userInfo,
  getSaleInfo,
  saleInfo,
  getSaleInfoDetail,
  addSaleDetail,
  getProcessParams,
  getExampleBusiness,
  creatExampleProcess,
  getExampleForm,
  complateExampleTask,
  getProcessDetail,
  getTaskList,
  getExampleqlList,
  getExamplemfcdList,
  getStartlList
}
